package br.com.timesystem.serviceimpl;

import br.com.timesystem.dao.GenericDAO;
import br.com.timesystem.service.GenericService;
import java.io.Serializable;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author duduso
 */
@Service("genericService")
@Transactional(readOnly = true)
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public class GenericServiceImpl<T> implements GenericService<T> {
    
    private static Log LOG = LogFactory.getLog(GenericServiceImpl.class);
    
    @Autowired
    private GenericDAO<T> genericDAO;

    @Override
    @Transactional(readOnly = false)
    public Serializable salvar(T value) {
        return this.genericDAO.salvar(value);
    }

    @Override
    @Transactional(readOnly = false)
    public void atualizar(T value) {
        this.genericDAO.atualizar(value);
    }

    @Override
    @Transactional(readOnly = false)
    public void salvarOuAtualizar(T value) {
        this.genericDAO.salvarOuAtualizar(value);
    }

    @Override
    @Transactional(readOnly = false)
    public void excluir(T value) {
        this.genericDAO.excluir(value);
    }

    @Override
    public T obterPorId(Class clazz, Serializable id) {
        return this.genericDAO.obterPorId(clazz, id);
    }
    
}
